$(function(){
	
//	获取活动奖励列表
function kkll(){
	$.ajax({
	    type:"post",
	    url:url+'/register/rewardindex.html?token='+token,
	    async:false,
	    data:{"token":token},
	    dataType:'json',
	    success:function(result){
	        if(result.status == "0001"){
	        	var data=result.data;
	        	var html = '';
	        	for(var i in data){
	        		html += '<li class="myrewa_item"><img src="../images/myrewa_pic.png" alt="" class="myrewa_pic" />';
					html += '<div class="myrewa_le"><p class="myrewa_let1">'+data[i].title+'</p>';
					html += '<p class="myrewa_let2">'+data[i].tips+'</p></div>';
					if(data[i].state == "0"){
						html += '<a href="javascript:;" class="myrewa_link">未达成</a></li>';
					}else if(data[i].state == "1"){
						html += '<a data="'+data[i].id+'" href="javascript:;" class="myrewa_link on kk_on">可领取</a></li>';
					}else{
						html += '<a href="javascript:;" class="myrewa_link">已领取</a></li>';
					}
					
	        	}
	        	$(".myrewa_list").html(html);
	        	//	领取
				$(".kk_on").on("click",function(){
					var id=$(this).attr("data");
					var d={};
					d.token=token;
					d.id=id;
					$.ajax({
					    type:"post",
					    url:url+'/register/receive.html?token='+token,
					    async:false,
					    data:d,
					    dataType:'json',
					    success:function(result){
					        if(result.status == "0001"){
					        	layer.msg(result.message);
					        	kkll();
					        }else{
					            isErr(result);
					        }
					    },
						error:function(){
							layer.msg("响应失败");
						}
					})
				})
			
	        }else{
	            isErr(result);
	        }
	    },
		error:function(){
			layer.msg("响应失败");
		}
	})
}
	kkll();
	

})